package com.founder.android.reader;

import android.app.Dialog;
import android.content.Context;
import android.view.Gravity;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.TextView;

public class LoadingDialog extends Dialog {
	private static LoadingDialog loadingDialog;
	public LoadingDialog(Context context) {
		super(context);
	}
	
	public LoadingDialog(Context context, int theme) {
		super(context, theme);
	}

	public static void show(Context context){
		loadingDialog = new LoadingDialog(context);
		loadingDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
		TextView tx = new TextView(context);
		tx.setText("Loading...");
		loadingDialog.setContentView(tx);
		
		Window window = loadingDialog.getWindow();
		window.setLayout(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
		
		window.setGravity(Gravity.CENTER_VERTICAL & Gravity.CENTER_HORIZONTAL);

		loadingDialog.show();
		
	}
	public static void shut(){
		if(loadingDialog!=null&&loadingDialog.isShowing()){
			loadingDialog.dismiss();
		}
	}
}
